<template>
<view :class="'container ' + ( isLoading ? 'hide' : '' )">
  <view class="infor">
    <view class="li first storext">
      <view class="img">
        <image :src="store.image"></image>
      </view>
      <view class="tit">{{ store.name }}</view>
    </view>
    <view class="answer clearfix">
      <view class="fl">订单￥{{ order.total_price }} 优惠-￥{{ order.discount_price }}</view>
      <view class="fr">应收总额: ￥{{ order.price }}</view>
    </view>
  </view>
  <view class="infor">
    <view class="li clearfix first">
      <view class="fl book">订单信息</view>
    </view>
    <view class="li clearfix">
      <view class="fl">订单编号</view>
      <view class="fr">{{ order.order_id }}</view>
    </view>
  </view>
  <view class="infor" v-if="order.paid == 1">
    <view class="li clearfix first">
      <view class="fl branch">支付信息</view>
    </view>
    <view class="li clearfix">
      <view class="fl">支付时间</view>
      <view class="fr">{{ order.pay_time_txt }}</view>
    </view>
    <view class="li clearfix">
      <view class="fl">支付方式</view>
      <view class="fr">{{ order.pay_type_str }}</view>
    </view>
    <view class="li clearfix">
      <view class="fl">应收总额</view>
      <view class="p90">
        <view class="e2c">￥{{ order.price }}</view>
      </view>
    </view>
    <view class="li clearfix" v-if="order.no_discount_money > 0">
      <view class="fl">不可优惠金额</view>
      <view class="p90">
        <p class="e2c">-￥{{ order.no_discount_money }}</p>
        <p class="kdsize">不可优惠金额不参与优惠</p>
      </view>
    </view>
    <view class="li clearfix" v-if="order.card_discount != 10">
      <view class="fl">商家会员卡折扣</view>
      <view class="p90">
        <view class="e2c">-￥{{ order.merchant_discount }}（{{ order.card_discount }}折）</view>
      </view>
    </view>
    <view class="li clearfix" v-if="order.card_price > 0">
      <view class="fl">商家优惠券</view>
      <view class="fr e2c">-￥{{ order.card_price }}</view>
    </view>
    <view class="li clearfix" v-if="order.coupon_price > 0">
      <view class="fl">平台优惠券</view>
      <view class="fr e2c">-￥{{ order.coupon_price }}</view>
    </view>
    <view class="li clearfix" v-if="order.score_deducte > 0">
      <view class="fl">积分抵扣</view>
      <view class="fr e2c">-￥{{ order.score_deducte }}（使用{{ order.score_used_count }}积分）</view>
    </view>
    <view class="li clearfix" v-if="order.card_give_money > 0">
      <view class="fl">会员卡赠送余额支付</view>
      <view class="fr e2c">-￥{{ order.card_give_money }}</view>
    </view>
    <view class="li clearfix" v-if="order.merchant_balance > 0">
      <view class="fl">商家余额支付</view>
      <view class="fr e2c">-￥{{ order.merchant_balance }}</view>
    </view>
    <view class="li clearfix" v-if="order.balance_pay > 0">
      <view class="fl">平台余额支付</view>
      <view class="fr e2c">-￥{{ order.balance_pay }}</view>
    </view>
    <view class="li clearfix" v-if="order.payment_money > 0">
      <view class="fl">{{ order.pay_type_str }}</view>
      <view class="fr e2c">-￥{{ order.payment_money }}</view>
    </view>
  </view>
</view>
</template>

"<script>
import common from '../../utils/common.js'
var app = getApp();

export default {
  data() {
    return {
      order_id: 0,
      isLoading: true,
      order: {},
      store: {}
    };
  },

  onShareAppMessage: function () {},
  onReachBottom: function () {},
  onPullDownRefresh: function () {},
  onUnload: function () {},
  onHide: function () {},
  onShow: function () {
	  // #ifdef H5
	  common.hideWxShare()
	  // #endif
  },
  onReady: function () {},
  onLoad: function (options) {
    this.setData({
      order_id: options.order_id
    });
    common.post('My&a=store_order_detail', {
      order_id: this.order_id
    }, "setMainContent", this);
  },
  components: {},
  props: {},
  methods: {
    setMainContent: function (result) {
      this.setData({
        order: result.order,
        store: result.store,
        isLoading: false
      });
      wx.hideToast();
    },
    setData: function (obj) {
      let that = this;
      let keys = [];
      let val, data;
      Object.keys(obj).forEach(function (key) {
        keys = key.split('.');
        val = obj[key];
        data = that.$data;
        keys.forEach(function (key2, index) {
          if (index + 1 == keys.length) {
            that.$set(data, key2, val);
          } else {
            if (!data[key2]) {
              that.$set(data, key2, {});
            }
          }

          data = data[key2];
        });
      });
    }
  }
};
</script>
<style>
.infor {
    background:#fff;
    margin-bottom:20rpx;
    font-size:28rpx;
}

.infor .li{
    line-height:40rpx;
    margin-left: 30rpx;
    padding: 20rpx 20rpx 20rpx 0;
    font-size: 28rpx;
    color: #666666;
    border-bottom: #f1f1f1 1rpx solid;
}
.infor li:last-child {
    border-bottom: none;
}
.infor li.first {
    font-size: 32rpx;
    color: #333333;
    padding: 20rpx;
    margin-left: 0px;
}
.infor .li.storext {
    margin-left: 20rpx;
    border-bottom: #f1f1f1 1rpx solid;
    position: relative;
    padding: 20rpx;
}
.infor .li.storext .img{
    width: 40rpx;
    height: 40rpx;
    position: absolute;
    left: 0px;
    top: 20rpx;
}
.infor .li.storext image {
    width: 40rpx;
    height: 40rpx;
    border-radius: 100%;
}
.infor .li.storext .tit {
    padding-left: 40rpx;
    overflow: hidden;
    color: #333333;
    word-break: keep-all;
    white-space: nowrap;
    text-overflow: ellipsis;
    padding-right: 40rpx;
}
.infor .li.storext:after {
    display: block;
    content: "";
    border-top: 1rpx solid #cccccc;
    border-left: 1rpx solid #cccccc;
    width: 16rpx;
    height: 16rpx;
    -webkit-transform: rotate(135deg);
    background-color: transparent;
    position: absolute;
    right: 20rpx;
    top: 30rpx;
}
.infor .answer {
    padding: 20rpx 20rpx 20rpx 0;
    margin-left: 20rpx;
    border-bottom: #f1f1f1 1rpx solid;
    line-height: 50rpx;
}
.infor .answer .fl {
    color: #666666;
    font-size:26rpx;
}
.infor .answer .fr {
    color: #ff372d;
}


.infor .li.first .fl {
    padding-left: 40rpx;
}
.infor .li.first .book {
    background: url(https://hf.pigcms.com/static/wxapp/kd-img1.png) left center no-repeat;
    background-size: 28rpx;
}
.infor .li.first .branch {
    background: url(https://hf.pigcms.com/static/wxapp/kd-img4.png) left center no-repeat;
    background-size: 28rpx;
}
.infor .li .p90 {
    padding-left: 180rpx;
    font-size: 26rpx;
    text-align: right;
}
.infor .li .e2c {
    color: #2ecc71;
}
</style>